<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/26
 * Time: 15:21
 */

namespace app\common\validate;


use think\Validate;

class Order extends Validate
{
    protected $rule = [
        'order_time|预约时间'  =>  'require|checkDate',
        'content|评价'  =>  'max:50',
        'score|评分'  =>  'require|between:1,5',
        'anonymous|匿名评价'  =>  'in:1,0',
//        'tags|评价标签'  =>  'require',

    ];

    protected $scene = [
        'add'=> ['order_time'],
        'edit'=> ['cid'],
        'evaluate'=> ['content','score','anonymous','tags'],
    ];
    protected function checkDate($value)
    {

        if (!is_numeric($value)) return '时间格式错误';

        if ($value < time()+60*25) return '预约时间需大于当前时间30分钟以上';

        return true;

    }


}